Repository navigation
Run each copy's patch engine behind a pointer, so the in-process gem tests fit their stack on Windows - #2432
Conversation
The in-process tests run a command on a libtest thread, which has a 2 MiB stack. The deepest chain there is scan -> the nested apply -> apply_gem_package_patch -> apply_package_patch -> the store-copy fan-out -> the engine. Every async fn on that chain awaits apply_package_patch inline, and a debug build keeps room for the awaited future in the caller's poll frame at each call site. The engine's future is the largest of them, so every caller up to the command carried it. apply_package_patch, rollback_package_patch and rollback_store_copies_holding_patch now build the per-copy engine future through a non-inlined boxed(), so their own futures hold a pointer. No behaviour changes. On macOS (arm64, debug) the smallest stack that remove_base_purl_clears_all_platforms_and_rolls_back of in_process_gem_multi_platform passes with goes from 1972 KiB to 1500 KiB. On Windows that test overflowed the stack on a branch that adds nothing to the chain beyond current main. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Core's boxed (for the patch engines) and the CLI's (for its command frames) are the same helper but for a Send bound. Each doc comment now names the other, so a change to one is made to both. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
PR SummaryLow Risk Overview Introduces a non-inlined The CLI’s existing Reviewed by Cursor Bugbot for commit 4124614. Configure here. |
|
[agent] PR shepherd: review brief for the approver What it does. The in-process gem tests nearly fill a test thread's 2 MiB stack, and on Windows debug they overflow it ( Risk: low. It adds one heap allocation per patched copy and keeps the same Look here
Verified
Changes I made. None. Open questions. None. The follow-up in the body (a test on a thread with a bounded stack, so a regression fails on every platform) is not needed for this PR. Generated by Claude Code |
Wenxin Jiang (Wenxin-Jiang)
left a comment
There was a problem hiding this comment.
[agent] Reviewed the full diff at 4124614: the three engine calls are boxed at the same await points with the same arguments and Send bound, so behaviour is unchanged apart from one allocation per copy. No defects found.
Resolve the conflict with main's file-mode support (#2433) and its boxed engine futures (#2432): - keep one `boxed` helper, main's (both sides added the same function); - thread main's new `mode` argument of `stage_write` through this branch's shared `stage`; the optional RECORD write passes `None`, so it clears no permission bits; - compute the sidecar fixup files once, before the RECORD plan, as this branch does, reading main's `(file, AppliedVia)` entries of `written`; - give this branch's tests the new `mode` field and argument. Assisted-by: Claude Code:claude-opus-5-5
…s-dir' into fix/vex-pnpm-store-windows The base branch took in main, which holds #2430 (the rule this branch extends) and the two fixes for the stack that the in-process gem tests overflow on Windows (#2402, #2432). Without them the Windows test shard fails on a test this branch does not touch. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The problem
The in-process CLI tests run a command on a libtest thread, which has a 2 MiB stack. On
mainthe gem tests ofin_process_gem_multi_platformuse nearly all of it: on macOS (arm64, debug)remove_base_purl_clears_all_platforms_and_rolls_backneeds 1,972 KiB of the 2,048. Windows debug frames are larger. PR runs and push runs have no Windows test job, so only the nightly and a dispatched run show it:mainitself overflows there since0a1709bb2(STATUS_STACK_OVERFLOWin that test), and so do open PRs built on it.Where the stack goes:
scan-> the nested apply ->apply_gem_package_patch->apply_package_patch-> the store-copy fan-out -> the engine. Everyasync fnon that chain awaitsapply_package_patchinline, and a debug build keeps room for the awaited future in the caller's poll frame at each call site. The engine's future is the largest of them, so every caller up to the command carried it.The change
apply_package_patch,rollback_package_patchandrollback_store_copies_holding_patchbuild the per-copy engine future through a small non-inlinedboxed()helper, so their own futures hold a pointer. Two files in core, 36 lines added. No behaviour changes.Measured
Smallest
RUST_MIN_STACKthatremove_base_purl_clears_all_platforms_and_rolls_backpasses with, macOS arm64 debug:main(0a1709bb2)mainafter #2402Windows: the Windows tier, run by dispatch.
main(0a1709bb2)remove_base_purl_clears_all_platforms_and_rolls_backoverflows its stack49a28f350)The head adds one commit of doc comments to the tested one.
Since those runs, #2402 landed. It boxes the hand-offs on the CLI side of the same chain, and its Windows tier passed, so
mainshould be back under the limit. This PR takes the engine's future out of every caller's frame, which is the larger share, and the two add up (last row of the table above). The merged tree compiles and lints clean.Review
/code-review highfound nothing blocking and two nits. Done: the helper is a twin of the CLI'secosystem_dispatch::boxedbut for aSendbound, so each doc comment now names the other. Not done: a test that runs the deepest chain on a thread with a stack bounded below 2 MiB, so that a regression fails on every platform and not only in the Windows nightly. A bound that is safe needs measuring on Linux and Windows as well (Linux needs more than macOS for the same test), so it is left for a follow-up; until then the Windows tier is the only detector.Tests
Run locally on the head commit:
cargo fmt --check,cargo clippy --workspace --all-features -- -D warnings,cargo check --workspace --all-targets --all-features, the core lib (8,818 passed), and the CLI lib (1,090),apply(207),rollback(142),remove(90),scan(268),get(162),vendor(146) andin_process_gem_multi_platform(9), all passing.🤖 Generated with Claude Code